package com.qyc.controller;

import com.qyc.annotation.SystemLog;
import com.qyc.service.AccountService;
import com.qyc.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @className: LoginController
 * @Description: 登录接口
 * @author: qinyc
 * @date: 2023/6/20 16:10
 * @version: v1.0
 */

@Api(tags = "登录模块")
@RestController
public class LoginController {

    @Autowired
    private AccountService accountService;

    /**
     * @Author qinyc
     * @Description  登录接口
     * @version: v1.0
     * @Date 16:30 2023/6/20
     **/
    @SystemLog(businessName = "登录接口")
    @ApiOperation("登录接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "用户名"),
            @ApiImplicitParam(name = "password",value = "密码")
    })
    @PostMapping("/login")
    public ResponseResult login(String username,String password){
        return accountService.login(username,password);
    }

    /**
     * @Author qinyc
     * @Description  退出登录
     * @version: v1.0
     * @Date 2:14 2023/6/21
     **/
    @SystemLog(businessName = "退出登录")
    @ApiOperation("退出登录接口")
    @GetMapping("/logout")
    public ResponseResult logout(){
        return ResponseResult.success();
    }

    /**
     * @Author qinyc
     * @Description  修改用户密码
     * @version: v1.0
     * @Date 16:10 2023/7/4
     **/
    @ApiOperation("修改用户密码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "oldPwd",value = "旧密码"),
            @ApiImplicitParam(name = "newPwd",value = "新密码"),
            @ApiImplicitParam(name = "rePasswd",value = "重复新密码")
    })
    @PutMapping("/base/account/passwd")
    public ResponseResult passwd(String oldPwd,String newPwd,String rePasswd){
        return ResponseResult.success();
    }
}
